/*
 * @Author: wangdian
 * @Date: 2023-06-08 17:08:03
 * @LastEditors: wangdian
 * @LastEditTime: 2023-08-16 11:10:25
 * @Description: file content
 * @FilePath: \workspace\express_demo.js
 */
//express_demo.js 文件
var express = require('express');
var app = express();

var bodyParser = require('body-parser');
// 创建 application/x-www-form-urlencoded 编码解析
var urlencodedParser = bodyParser.urlencoded({ extended: false })
app.get('/use', function (req, res) {
    res.send({
        name: 'wangdain',
    });
})

app.post('/ycgl/websocket', urlencodedParser, function (req, res) {

    // 输出 JSON 格式
    response = {
        mode: req.body.mode,
        urlencoded: req.body.urlencoded
    };
    console.log(response);
    res.end(JSON.stringify(response));
})

app.get('/websocket/stop', (req, res) => {
    res.send({
        code: 200,
    });
})


var server = app.listen(8088, function () {
    var host = server.address().address
    var port = server.address().port
    console.log("应用实例，访问地址为 http://%s:%s", host, port)
    // console.log('Server running at http://127.0.0.1:8888/');
})